package com.rosiminc.pwt.game;

public class PWTGame {
	/*private Entity[][] room;*/
	
	private int width = 10;
	private int height = 8;
	
	private Player player;
	
	public PWTGame(int width, int height){
		player = new Player(0,0);
		this.width = width;
		this.height = height;
	}
	
	public Player getPlayer()
	{
		return player;
	}
	
	public String toString()
	{
		StringBuilder bld = new StringBuilder();
		for(int i=0; i<height; i++)
		{
			for(int j=0; j<width; j++)
			{
				bld.append(i==player.y&&
						j==player.x? "P" : ".");
			}
			bld.append("\n");
		}
		return bld.toString();
	}
	
	public class Player{
		
		int x=0; 
		int y=0;
		
		public Player(int x, int y)
		{
			this.x = x;
			this.y = y;
		}
		
		public int getX()
		{
			return x;
			
		}
		
		public int getY()
		{
			return y;
			
		}
		
		
		public boolean moveUp()
		{
			if(y <= 0)
				return false;
			y--;
			return true;
		}
		
		public boolean moveDown()
		{
			if(y >= height-1)
				return false;
			y++;
			return true;
		}
		
		public boolean moveLeft()
		{
			if(x <= 0)
				return false;
			x--;
			return true;
		}
		
		public boolean moveRight()
		{
			if(x >= width-1)
				return false;
			x++;
			return true;
		}
	}
}
